﻿using System;
using System.Collections.Generic;
using System.Text;
using ZLDC.Common.Estate;
using System.Data;
using ZLDC.Topo.Model.Estate;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

namespace ZLDC.Topo.BLL.Estate
{
    public class EstatePicBLL
    {
        public static int SavePic(List<Thumbnail> list, string type, int eid, string ename, int bid, string bname, string[] Array, string[] Array1)
        {
            string userId = _Utility.GetInfoBySession().m_sUserID;
            string deptId = _Utility.GetInfoBySession().m_sDeptID;
            string deptName = _Utility.GetInfoBySession().m_sDeptName;
            string userName = _Utility.GetInfoBySession().m_sUserName;

            return ZLDC.DAL.Estate.EstatepicDAL.SavePic(list, type, eid, ename, bid, bname, Array, Array1, userId, userName, deptId, deptName);
        }

                                                        public static string EstatePicList(int eid, int type)
        {
            DataTable dt = null;

            using (_Database db = new _Database("estate"))
            {
                dt = ZLDC.DAL.Estate.EstatepicDAL.p_estate_pic_listall_table(eid, type, db);
            }

            _Json json = new _Json(dt, "yyyy-MM-dd HH:mm:ss");
            return "{record:" + json.ToJson() + "}";        
        }
                public static int EstateCoutnPic(int eid, int type)
        {
            DataTable dt = null;

            using (_Database db = new _Database("estate"))
            {
                dt = ZLDC.DAL.Estate.EstatepicDAL.p_estate_pic_listall_table(eid, type, db);
            }

            return dt.Rows.Count;
        }
                public static string DelPic(int id,int deptid)
        {
            string outmsg = "";
            int rows = 0;
            using (_Database db = new _Database("estate")) 
            {
                rows = ZLDC.DAL.Estate.EstatepicDAL.DelPic(id,deptid,db);
                if (rows > 0)
                {
                    outmsg = "删除成功";
                    ZLDC.Topo.BLL.Estate.OperationlogBLL.p_operationlog_insert("t_housing_pic", id, 1, "删除图片");

                }
                else 
                {
                    outmsg = "对不起，你没有权限删除该图片！";
                }
            }
            return outmsg;
        }
    }
}
